package design.patterns.behavioral.state;

/**
 * @author gjx
 * @version v1.0
 * @Description
 * @date 2019/4/10 14:44
 */
public class Hero {
    private HeroState runState;//当前状态

    public static RunHeroState runHeroState;
    public static AttackHeroState attackHeroState;
    public static FrozenHeroState frozenHeroState;

    static {
        runHeroState = new RunHeroState();
        attackHeroState = new AttackHeroState();
        frozenHeroState = new FrozenHeroState();
    }

    public HeroState getRunState() {
        return runState;
    }

    public void setRunState(HeroState runState) {
        this.runState = runState;
        this.runState.setHero(this);
    }

    public void run(){
        runState.run();
    }

    public void attack(){
        runState.attack();
    }

    public void frozen(){
        runState.frozen();
    }
}
